
#pragma once
 
#include "./tinyxml2.h" 

#include "./fore_rtdb.h"
#include "./base.h"

#include "./rtdbFun.h"

#include "./rtdb_fun.h" 

#include "./my_mqtt.h"

#include <iostream>
#include <string>
#include <string.h>
#include <stdlib.h>
   
#include <map>
#include <vector>

using namespace std;



struct STRU_PROPERTY
{
	char    propertyName[32];
	char	dataType[32];
	bool	required;
	char	min[12];
	char	max[12];
	float	step;
	int	maxLength;
	char	method[32];
	char	unit[12]; 
	int	zfType; 

	STRU_PROPERTY()
	{
		memset(this, 0, sizeof(STRU_PROPERTY));
	}
};
 
 
 
 struct STRU_PROPERTY_SERVICEOBJ
{

};
 

struct STRU_PROFILE_SERVICEID
{
	char	manufacturerName[32];
	char	manufacturerId[32];
	char	model[32];
	char	protocolType[12];
	char	deviceType[32];
	char	omCapability[12];
	
	 
	char	serviceId[32];

	std::vector<STRU_PROPERTY>   aryProperty;

	//std::map<std::string, std::vector<STRU_PROPERTY> >   mapServerIdToProperty;

	STRU_PROFILE_SERVICEID()
	{
		memset(this, 0, sizeof(STRU_PROFILE_SERVICEID));
	}
};
  
struct FORE_DEVTYPE_ADDR_CFG   
{
	FORE_DEVTYPE_ADDR_CFG()
	{
		memset( this, 0, sizeof(FORE_DEVTYPE_ADDR_CFG));
	} 

	char		dev_type[32];
	char		dev_type_name[32];

	char		profilename[32];

	char        dev_stAddr[13];    //��Ӧ�豸��ַ  modbus 1���ֽڣ� 645 6���ֽ�
	char		dev_endAddr[13]; 
	  
};
 

class CReadCfg
{
public:
	CReadCfg() ;
	~CReadCfg();


public:  

	
	
 
	void process_rtdb();
 
private:
	 
	bool load_dev_model_json( char* profile_devtype_filename, FORE_DEV_TYPE & devType );

	bool LoadDevTypeCfg( std::vector<FORE_DEV_TYPE> & aryDevType );  
	 
	bool InsertProfileToRtdb( );

	void ClearVector(); 
public:
	string 							m_strAppName;
	
	bool 							m_mqtt_result;
	bool 							m_re_init_db;
	
	CMyMQTTAsync						m_MqttCli;
private: 
	 
	std::vector<STRU_PROFILE_SERVICEID>   			m_aryServiceObjs; 
 

};
